package com.ts.common.util;

import com.ts.web.dao.ICommonDao;
import com.ts.web.dao.impl.CommonDao;
import com.ts.web.service.ICommonService;
import com.ts.web.service.impl.CommonService;


public class BeanFactory {

	

	
	public static final String COMMONDAO = "commonDao";

	public static final String COMMONSERVICE = "commonService";
	

	private static ICommonDao commonDao;
	private static ICommonService commonService;

	public static Object getBean(String beanName) {

	
		if (beanName.equals("commonDao")) {
			commonDao = getCommonDao();
			return commonDao;
		}
		if (beanName.equals("commonService")) {
			commonService = getCommonSerivce();
			return commonService;
		}

		return null;
	}

	

	synchronized private static ICommonDao getCommonDao() {
		if (commonDao == null)
			commonDao = new CommonDao();
		return commonDao;
	}

	synchronized private static ICommonService getCommonSerivce() {
		if (commonService == null)
			commonService = new CommonService();
		return commonService;
	}
}
